<?php /*a:1:{s:62:"D:\web\wwwroot\tp5.1\application/admin/view\article\index.html";i:1517366811;}*/ ?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>表格</title>
    <link rel="stylesheet" href="/static/frame/layui/css/layui.css">
    <link rel="stylesheet" href="/static/frame/static/css/style.css">
    <link rel="icon" href="/static/frame/static/image/code.png">
</head>
<body class="body">



<div class="tab-top">
  <a class="layui-btn site-demo-active layui-btn-sm" data-type="tabAdd" href="<?php echo url('admin/Article/add'); ?>"><i class="layui-icon">&#xe608;</i>添加文章</a>

<div class="search">
  <form class="layui-form" action="">
  <div class="layui-inline">
    <input class="layui-input layui-input-sm" name="search" placeholder="请输入文章标题" id="search-elm" autocomplete="off" value="<?php echo htmlentities($search); ?>">
  </div>
  <button class="layui-btn site-demo-active layui-btn-sm search-btn" data-type="reload">搜索</button>
</form>
</div>

</div>


<div class="layui-form">
  <table class="layui-table" lay-filter="parse-table-demo" id="test33">
      <colgroup>
    <col width="50">
    <col width="80">
    <col minwidth="300">
    <col width="180">
    <col width="100">
    <col width="150">
    <col width="150">
    <col width="128">
    <col>
  </colgroup>
    <thead>
      <tr>
        <th lay-data="{type:'checkbox'}"><input type="checkbox" name="" lay-skin="primary" lay-filter="allChoose"></th>
        <th lay-data="{field:'id', width:80, sort: true}">ID</th>
        <th lay-data="{field:'title', minwidth:300}">标题</th>
        <th lay-data="{field:'typename', width:180,}">栏目</th>
        <th lay-data="{field:'click', width:100}">点击</th>
        <th lay-data="{field:'write', width:150}">作者</th>
        <th lay-data="{field:'update_time', width:150}">时间</th>
        <th lay-data="{fixed: 'right', width:128, align:'center', toolbar: '#barDemo'}">操作</th>
      </tr> 
    </thead>
    <tbody>
<?php foreach($list as $key=>$vo): ?> 
      <tr>
        <td><input type="checkbox" name="" lay-skin="primary" data-id="<?php echo htmlentities($vo['id']); ?>"></td>
        <td><?php echo htmlentities($vo['id']); ?></td>
        <td><?php echo htmlentities($vo['title']); if(!(empty($vo['article_img']) || (($vo['article_img'] instanceof \think\Collection || $vo['article_img'] instanceof \think\Paginator ) && $vo['article_img']->isEmpty()))): ?> <span class="layui-badge layui-bg-green"><i class="layui-icon">&#xe64a;</i></span><?php endif; ?></td>
        <td><?php echo htmlentities($vo->arctype->title); ?></td>
        <td><?php echo htmlentities($vo['click']); ?></td>
        <td><?php echo htmlentities($vo['write']); ?></td>
        <td><?php echo htmlentities(date('Y-m-d H:i',!is_numeric($vo['update_time'])? strtotime($vo['update_time']) : $vo['update_time'])); ?></td>
        <td> <a class="layui-btn layui-btn-xs" href="<?php echo url('admin/Article/edit',['id'=>$vo['id']]); ?>"><i class="layui-icon">&#xe642;</i></a>  <a class="layui-btn layui-btn-danger layui-btn-xs article-del" data-href="<?php echo url('admin/Article/delete',['id'=>$vo['id']]); ?>"><i class="layui-icon">&#xe640;</i></a></td>
      </tr>
<?php endforeach; ?>
    </tbody>
  </table>

</div>

<div class="list-page"><?php echo $page; ?></div>

 <a class="layui-btn site-demo-active layui-btn-sm" data-type="tabdel" id="alldel"><i class="layui-icon">&#xe608;</i>批量删去</a>
<script type="text/javascript" src="/static/frame/layui/layui.js"></script>
<script src="/static/admin/js/comm.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
layui.use(['form','table','admin'], function(){
  var $ = layui.jquery
      ,form = layui.form
      ,table = layui.table
      ,admin = layui.admin;
  
  //全选
    form.on('checkbox(allChoose)', function(data){
      var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
      child.each(function(index, item){
        item.checked = data.elem.checked;
      });
      form.render('checkbox');
    });


    $('.article-del').on('click',function(){
          href = $(this).attr('data-href');
          trelm = $(this).parents('tr');
          layer.confirm('真的删除行么', function(){
          $.get(href,function(data){
          if (data.code == 1) {
            layer.msg(data.msg);
            trelm.remove(); //js删去当前行
          }else{
            layer.msg(data.msg);
          }
          });
        });
    });

  $('#alldel').on('click',function(){
  ids = admin.getIds($('#test33'),'data-id'); //得到 1，2，4
  url = "<?php echo url('admin/Article/delall'); ?>";
  
  sUrl = "<?php echo url('admin/Article/index'); ?>";
  eUrl = "<?php echo url('admin/Article/index'); ?>";
  //deleteAll(ids,请求的url,操作成功跳转url,操作失败跳转url)
  admin.deleteAll(ids, url, sUrl, eUrl);
  
  });
  


   $('.search-btn').on('click', function(){
    //$('#search-elm').val();
    location.href = '<?php echo url('admin/Article/index'); ?>?search='+$('#search-elm').val();
    //active[type] ? active[type].call(this) : '';
    return false;
  });


});

</script>
</body>
</html>